package com.boot.system.controller;

import com.boot.common.anno.AnnoLog;
import com.boot.common.anno.RepeatSubmit;
import com.boot.common.result.Result;
import com.boot.system.service.ModuleService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RequiredArgsConstructor
@RestController
@RequestMapping("/module")
public class ModuleController {

    private final ModuleService moduleService;

    @AnnoLog(value = "字典模块")
    @RepeatSubmit
    @PostMapping("/add")
    public Result<?> addModule(@RequestBody Map<String, Object> dataParam) {
        return moduleService.addModule(dataParam);
    }

    @AnnoLog(value = "模块修改")
    @RepeatSubmit
    @PostMapping("/update")
    public Result<?> updateModule(@RequestBody Map<String, Object> dataParam) {
        return moduleService.updateModule(dataParam);
    }

    @AnnoLog(value = "模块删除")
    @RepeatSubmit
    @PostMapping("/delete")
    public Result<?> deleteModule(@RequestBody Map<String, Object> dataParam) {
        return Result.success(moduleService.deleteModule((String) dataParam.get("ids")));
    }

    @AnnoLog(value = "模块列表")
    @PostMapping("/list")
    public Result<?> moduleList(@RequestBody Map<String, Object> queryParam) {
        return Result.success(moduleService.getModulePage(queryParam));
    }

    @AnnoLog(value = "模块详情")
    @GetMapping("/info")
    public Result<?> moduleInfo(@RequestParam("mid") String mid) {
        return moduleService.getModuleInfo(mid);
    }

}
